package test;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;

public class SerializeTest1 {
	public SerializeTest1(int c) {
		System.out.println("super cons with 1param");

	}

//	public SerializeTest1() {
//		System.out.println("super cons");
//	}

	/**
	 * 
	 */
	private static final long serialVersionUID = 2L;
	int a;
	Integer b;
	Integer c;

	private void readObject(ObjectInputStream in) throws ClassNotFoundException, IOException {
		System.out.println("readObject");
		in.defaultReadObject();
	}

	private void writeObject(ObjectOutputStream out) throws IOException {
		System.out.println("writeObject");
		out.defaultWriteObject();

	}

	private void readObjectNoData() {
		System.out.println("readObjectNoData");
	}

	public static void main(String[] args) throws IOException, ClassNotFoundException {
		SerializeTest1_1 s = new SerializeTest1_1();
		s.a = 99;
		s.b = 98;
		s.s = "aaa";
		System.out.println(s);
		ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream("c:/a.ser"));
		out.writeObject(s);
		out.close();
		ObjectInputStream in = new ObjectInputStream(new FileInputStream("c:/a.ser"));
		Object o = in.readObject();
		in.close();
		System.out.println(o);
	}

	@Override
	public String toString() {
		return "SerializeTest1 [a=" + a + ", b=" + b + "]";
	}

}

class SerializeTest1_1 extends SerializeTest1 implements Serializable {
	String s;

	public SerializeTest1_1() {
		super(3);

	}

	@Override
	public String toString() {
		return super.toString() + "SerializeTest1_1 [s=" + s + "]";
	}

}
